const models = require('../models')

const QuoteVolumeModel = models.QuoteVolume

/**
 * 基本
 */

exports.QuoteVolumeModel = QuoteVolumeModel

exports.newAndSave = function (data) {
  const QuoteVolume = new QuoteVolumeModel(data)
  return QuoteVolume.save()
}

exports.delete = function (query) {
  return QuoteVolumeModel.remove(query)
}

exports.batchDeleteByIds = function (ids) {
  return QuoteVolumeModel.remove({ _id: { $in: ids || [] } })
}

exports.update = function (query, data) {
  return QuoteVolumeModel.update(query, {
    $set: data
  })
}

exports.find = function (query, opt) {
  return QuoteVolumeModel.find(query, {}, opt)
}

exports.findWidthField = function (query, field, opt) {
  return QuoteVolumeModel.find(query, field || {}, opt)
}
exports.findOne = function (query) {
  return QuoteVolumeModel.findOne(query)
}

exports.findOneById = function (id) {
  return QuoteVolumeModel.findById(id)
}

exports.check = function (query, opt) {
  return QuoteVolumeModel.findOne(query, '_id', opt)
}

exports.count = function (query) {
  return QuoteVolumeModel.count(query)
}
